<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>通知组件 - 组件演示</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../components/notification/notification.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>🚀 openHarmony_Cordova_NutpiDesign</h1>
            <p class="subtitle">组件演示 - 通知组件</p>
        </header>

        <nav class="demo-nav">
            <a href="../index.html" class="nav-back">← 返回首页</a>
        </nav>

        <main class="main-content">
            <section class="demo-section">
                <h2>🔔 通知组件演示</h2>
                
                <div class="demo-container">
                    <div class="demo-item">
                        <h3>信息通知</h3>
                        <button id="infoBtn" class="demo-btn">打开</button>
                    </div>

                    <div class="demo-item">
                        <h3>成功通知</h3>
                        <button id="successBtn" class="demo-btn">打开</button>
                    </div>

                    <div class="demo-item">
                        <h3>错误通知</h3>
                        <button id="errorBtn" class="demo-btn">打开</button>
                    </div>

                    <div class="demo-item">
                        <h3>警告通知</h3>
                        <button id="warningBtn" class="demo-btn">打开</button>
                    </div>

                    <div class="demo-item">
                        <h3>左上角</h3>
                        <button id="topLeftBtn" class="demo-btn">打开</button>
                    </div>

                    <div class="demo-item">
                        <h3>右下角</h3>
                        <button id="bottomRightBtn" class="demo-btn">打开</button>
                    </div>

                    <div class="demo-item">
                        <h3>自动关闭</h3>
                        <button id="autoCloseBtn" class="demo-btn">打开</button>
                    </div>

                    <div class="demo-item">
                        <h3>不自动关闭</h3>
                        <button id="noAutoCloseBtn" class="demo-btn">打开</button>
                    </div>
                </div>
            </section>

            <section class="demo-section">
                <h2>使用代码</h2>
                <pre><code>// 1. 引入文件
&lt;link rel="stylesheet" href="components/notification/notification.css"&gt;
&lt;script src="components/notification/notification.js"&lt;/script&gt;

// 2. 创建通知
new Notification({
    message: '操作成功',
    type: 'success',
    duration: 3000,
    position: 'top-right',
    onClose: () => {
        console.log('通知已关闭');
    }
});</code></pre>
            </section>
        </main>

        <footer class="footer">
            <p>&copy; 2025 OpenHarmony 三方库适配中心 | MIT License</p>
        </footer>
    </div>

    <script src="../components/notification/notification.js"></script>
    <script>
        document.getElementById('infoBtn').addEventListener('click', () => {
            new Notification({
                message: '这是一条信息提示',
                type: 'info'
            });
        });

        document.getElementById('successBtn').addEventListener('click', () => {
            new Notification({
                message: '操作成功完成',
                type: 'success'
            });
        });

        document.getElementById('errorBtn').addEventListener('click', () => {
            new Notification({
                message: '操作失败，请重试',
                type: 'error'
            });
        });

        document.getElementById('warningBtn').addEventListener('click', () => {
            new Notification({
                message: '这是一条警告信息',
                type: 'warning'
            });
        });

        document.getElementById('topLeftBtn').addEventListener('click', () => {
            new Notification({
                message: '左上角通知',
                position: 'top-left',
                type: 'info'
            });
        });

        document.getElementById('bottomRightBtn').addEventListener('click', () => {
            new Notification({
                message: '右下角通知',
                position: 'bottom-right',
                type: 'success'
            });
        });

        document.getElementById('autoCloseBtn').addEventListener('click', () => {
            new Notification({
                message: '2秒后自动关闭',
                duration: 2000,
                type: 'info'
            });
        });

        document.getElementById('noAutoCloseBtn').addEventListener('click', () => {
            new Notification({
                message: '不会自动关闭，点击关闭按钮手动关闭',
                duration: 0,
                type: 'warning'
            });
        });
    </script>

    <style>
        .demo-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        .demo-item {
            background: var(--bg-light);
            padding: 16px;
            border-radius: 8px;
            text-align: center;
        }

        .demo-item h3 {
            margin-top: 0;
            margin-bottom: 16px;
            font-size: 14px;
            color: var(--text-primary);
        }

        .demo-btn {
            padding: 8px 16px;
            background: var(--primary-color);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 13px;
            transition: var(--transition);
        }

        .demo-btn:hover {
            opacity: 0.8;
        }
    </style>
</body>
</html>
